<?php
namespace app\admin\controller\system;
use app\common\annotation\NodeAnnotation;
use app\common\controller\Admin;
use app\common\traits\ControllerCurd;
use think\Request;
/**
 * @package app\admin\controller\system
 * @NodeAnnotation(
 *     title="订阅模块",
 *     is_menu=0,
 *     is_view=0
 * )
 */
class Subscribe extends Admin
{
    use ControllerCurd;
    public $model;

    public function initialize()
    {
        parent::initialize();
        $this->model= new \app\admin\model\system\SubscribeModel();
    }

    /**
     * @NodeAnnotation(
     *     title="订阅列表",
     *     parent="admin/system.Subscribe",
     *     MenuRoot="admin/system.setting"
     * )
     */
    public function index(Request $request)
    {
        $keywords  = $request->param("keywords");

        $where = [];

        if($keywords) array_push($where,['channel',"like","%$keywords%"]);

        $this->assign([
            "dataList" => $this->model->where($where)->order("update_time desc")->paginate(),
            "search" => [
                "keywords" => $keywords
            ]
        ]);

        return $this->fetch();
    }


    /**
     * @NodeAnnotation(
     *     title="删除订阅",
     *     parent="admin/system.subscribe",
     *     MenuRoot="admin/system.setting",
     *     is_view=0,
     *     is_menu=0
     * )
     */
    public function delsub(Request $request)
    {
        $this->del();
    }

}